﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace sqxt
{
    public partial class Mainform : Form
    {
        public Mainform()
        {
            InitializeComponent();
        }
        public static string yh;//记录登录的用户
        public Mainform(bool b,string ue)
        {

           
            Splasher.Status = "验证密码..............";
            System.Threading.Thread.Sleep(300);
            Splasher.Status = "验证密码成功";
            System.Threading.Thread.Sleep(200);
            Splasher.Status = "加载组件...............";
            System.Threading.Thread.Sleep(200);
            Splasher.Status = "请稍候................";
            System.Threading.Thread.Sleep(500);

            Splasher.Close();
            yh = ue;
        }
        private bool HaveOpened(Form frmName, string strFrmName) //查看窗口是否被打开构造函数
        {
            //查看窗口是否已经被打开
            bool bReturn = true;
            for (int i = 0; i < frmName.MdiChildren.Length; i++)//遍历窗体的子窗体
            {
                if (frmName.MdiChildren[i].Text == strFrmName)
                {
                    frmName.MdiChildren[i].BringToFront();
                    bReturn = false;
                    break;
                }
            }
            return bReturn;//没有打开时返回
        }

        private void buttonItem3_Click(object sender, EventArgs e)  //打开居民名册页面
        {
            try
            {
                beadroll beadroll = new beadroll();
                if (HaveOpened(this, "beadroll"))
                {
                    beadroll.MdiParent = this; //母窗体为本窗体
                    beadroll.WindowState = FormWindowState.Maximized;//打开时最大化
                    beadroll.Show();
                }
            }
            catch (SqlException se) { }


        }

        private void Mainform_Load(object sender, EventArgs e)
        {
            this.IsMdiContainer = true;//该页面为母窗体
            this.buttonItem2_Click(sender, e);
        }



        private void buttonItem2_Click(object sender, EventArgs e)
        {
            try
            {
            remind remind = new remind();
            if (HaveOpened(this, "remind"))
            {
              
                remind.MdiParent = this;
                remind.WindowState = FormWindowState.Maximized;
                remind.Show();
            }
        }
        catch (SqlException se) { }

        }

        private void buttonItem10_Click(object sender, EventArgs e)
        {
            try
            {
            builduser builduser = new builduser();
            if (HaveOpened(this, "builduser"))
            {
                builduser.MdiParent = this;
                builduser.WindowState = FormWindowState.Maximized;
                builduser.Show();
            }
        }
        catch (SqlException se) { }
        }

        private void buttonItem11_Click(object sender, EventArgs e)
        {

            try
            {
            addr addr = new addr();
            if (HaveOpened(this, "addr"))
            {
                addr.MdiParent = this;
                addr.WindowState = FormWindowState.Maximized;
                addr.Show();
            }
        }
        catch (SqlException se) { }

        }

        private void buttonItem9_Click(object sender, EventArgs e)
        {
            try
            {
            MedSite_wh MedSite_wh = new MedSite_wh();
            if (HaveOpened(this, "MedSite_wh"))
            {
                MedSite_wh.MdiParent = this;
                MedSite_wh.WindowState = FormWindowState.Maximized;
                MedSite_wh.Show();
            }
        }
        catch (SqlException se) { }
        }

        private void buttonItem4_Click(object sender, EventArgs e)
        {
            try
            {
            Hypertension Hypertension = new Hypertension();
            //hpt.Show();
            if (HaveOpened(this, "Hypertension"))
            {
                Hypertension.MdiParent = this;
                Hypertension.WindowState = FormWindowState.Maximized;
                Hypertension.Show();
            }
        }
        catch (SqlException se) { }
        }
        private void buttonItem1_Click(object sender, EventArgs e)
        {
            try{
            medsite_survey medsite_survey = new medsite_survey();
            if (HaveOpened(this, "medsite_survey"))
            {
                medsite_survey.MdiParent = this;
                medsite_survey.WindowState = FormWindowState.Maximized;
                medsite_survey.Show();
            }
        }
        catch (SqlException se) { }
            }


        private void buttonItem7_Click(object sender, EventArgs e)
        {
            try
            {
            TheOldsFrom TheOldsFrom = new TheOldsFrom();
            if (HaveOpened(this, "TheOldsFrom"))
            {
                TheOldsFrom.MdiParent = this;
                TheOldsFrom.WindowState = FormWindowState.Maximized;
                TheOldsFrom.Show();
            }
        }
        catch (SqlException se) { }

        }

        private void buttonItem12_Click(object sender, EventArgs e)
        {
            try
            {
            ReportFroms ReportFroms = new ReportFroms();
            if (HaveOpened(this, "ReportFroms"))
            {
                ReportFroms.MdiParent = this;
                ReportFroms.WindowState = FormWindowState.Maximized;
                ReportFroms.Show();
            }
        }
        catch (SqlException se) { }
        }

        private void buttonItem8_Click(object sender, EventArgs e)//孕产妇
        {
            try
            {
            Lactation_Form LactationForm = new Lactation_Form();
            if (HaveOpened(this, "LactationForm"))
            {
                LactationForm.MdiParent = this;
                LactationForm.WindowState = FormWindowState.Maximized;
                LactationForm.Show();
            }
        }
        catch (SqlException se) { }

        }

        private void buttonItem13_Click(object sender, EventArgs e)
        {
            try
            {
            TheDisabledForm TheDisabledForm = new TheDisabledForm();
            if (HaveOpened(this, "TheDisabledForm"))
            {
                TheDisabledForm.MdiParent = this;
                TheDisabledForm.WindowState = FormWindowState.Maximized;
                TheDisabledForm.Show();
            }
        }
        catch (SqlException se) { }
        }

        private void buttonItem6_Click(object sender, EventArgs e)
        {
            try
            {
                Childrens Childrens = new Childrens();
                if (HaveOpened(this, "Childrens"))
                {
                    Childrens.MdiParent = this;
                    Childrens.WindowState = FormWindowState.Maximized;
                    Childrens.Show();
                }
            }
            catch (SqlException se) {
                MessageBox.Show(se.Message);
            }
        }

        private void buttonItem4_Click_1(object sender, EventArgs e)
        {
            try
            {
                Hypertension Hypertension = new Hypertension();
                if (HaveOpened(this, "Hypertension"))
                {
                    Hypertension.MdiParent = this;
                    Hypertension.WindowState = FormWindowState.Maximized;
                    Hypertension.Show();
                }
            }
            catch (SqlException se) { }
        }

        private void buttonItem5_Click(object sender, EventArgs e)
        {
            try
            {
                diabete diabete = new diabete();
                if (HaveOpened(this, "diabete"))
                {
                    diabete.MdiParent = this;
                    diabete.WindowState = FormWindowState.Maximized;
                    diabete.Show();
                }
            }
            catch (SqlException se) { }
        }

       

    
        }

        }
        
        
